import { ItemData } from "../../../resource/info/ItemData";
import { EPlayerItemPosType } from "../../../../../Message/Public/EPlayerItemPosType";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { ItemFeatureTips } from "../../pack/social/ItemFeatureTips";
import { ItemsUtil } from "../../shortcuts/item/ItemsUtil";
import { EEquip } from "../../../../../Message/Public/EEquip";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { ECategory } from "../../../../../Message/Public/ECategory";
import { MountConfig } from "../../../resource/MountConfig";
import { Language } from "../../../../../extend/language/Language";
import { USE } from "../../../../../ItemMenuConst/USE";
import { BULKUSE } from "../../../../../ItemMenuConst/BULKUSE";
import { SHOW } from "../../../../../ItemMenuConst/SHOW";
import { TO_SALE } from "../../../../../ItemMenuConst/TO_SALE";
import { SPLIT } from "../../../../../ItemMenuConst/SPLIT";
import { DISPOSE } from "../../../../../ItemMenuConst/DISPOSE";
import { EQUIP } from "../../../../../ItemMenuConst/EQUIP";
import { MOVETOWARDROBE } from "../../../../../ItemMenuConst/MOVETOWARDROBE";
import { FORGING } from "../../../../../ItemMenuConst/FORGING";
import { IDENTIFYFABAO } from "../../../../../ItemMenuConst/IDENTIFYFABAO";
import { EQUIPFABAO } from "../../../../../ItemMenuConst/EQUIPFABAO";
import { DRESS_PETEQUIP } from "../../../../../ItemMenuConst/DRESS_PETEQUIP";
import { UNDRESS_PETEQUIP } from "../../../../../ItemMenuConst/UNDRESS_PETEQUIP";
import { UNDRESSALL_PETEQUIP } from "../../../../../ItemMenuConst/UNDRESSALL_PETEQUIP";
import { EQUIPMOUNT } from "../../../../../ItemMenuConst/EQUIPMOUNT";
import { JEWELUP } from "../../../../../ItemMenuConst/JEWELUP";
import { INSERT } from "../../../../../ItemMenuConst/INSERT";
import { FEED } from "../../../../../ItemMenuConst/FEED";
import { CRAVE } from "../../../../../ItemMenuConst/CRAVE";
import { DISPOSE_SKILLCARD } from "../../../../../ItemMenuConst/DISPOSE_SKILLCARD";
//class ItemMenuConst
    
    export  class ItemMenuConst
    {
        

        public static opearte(arg1: string, arg2: ItemData): void
        {
            var loc1=arg1;
            switch (loc1) 
            {
                case ItemMenuConst.USE:
                {
                    if (arg2.posType != EPlayerItemPosType._EPlayerItemPosTypeBag) 
                    {
                    };
                    Dispatcher.dispatchEvent(new DataEvent(EventName.BackPack_Use, arg2));
                    break;
                }
                case ItemMenuConst.SHOW:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.ChatShowItem, arg2));
                    break;
                }
                case ItemMenuConst.TO_SALE:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.MarketOpenSell, arg2));
                    break;
                }
                case ItemMenuConst.SPLIT:
                {
                    ItemFeatureTips.splitTip(arg2);
                    break;
                }
                case ItemMenuConst.DISPOSE:
                {
                    ItemFeatureTips.destroyItem(arg2);
                    break;
                }
                case ItemMenuConst.FORGING:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.Equipment_DoCast_Strengthen, arg2));
                    break;
                }
                case ItemMenuConst.EQUIP:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.BackPack_Equip, arg2));
                    break;
                }
                case ItemMenuConst.EQUIPFABAO:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.BackPack_EquipFabao, arg2));
                    break;
                }
                case ItemMenuConst.IDENTIFYFABAO:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.BackPack_IdentifyFabao, arg2));
                    break;
                }
                case ItemMenuConst.MOVETOWARDROBE:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.MoveToWardrobe, arg2));
                    break;
                }
                case ItemMenuConst.EQUIPMOUNT:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.BackPack_EquipMount, arg2));
                    break;
                }
                case ItemMenuConst.GRADE:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.BackPack_Grade, arg2));
                    break;
                }
                case ItemMenuConst.BULKUSE:
                {
                    if (ItemsUtil.isTreasureBoxProp(arg2) || ItemsUtil.isTreasureBoxKeyProp(arg2)) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.TreasureBoxPropUsedOpen, arg2));
                    }
                    else 
                    {
                        ItemFeatureTips.bulkUse(arg2);
                    }
                    break;
                }
                case ItemMenuConst.JEWELUP:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.Equipment_DoCast_ComposeJewel, arg2));
                    break;
                }
                case ItemMenuConst.DRESS_PETEQUIP:
                {
                    if (ItemsUtil.isMountEquipt(arg2)) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.BackPack_Equip, arg2));
                        break;
                    }
                    Dispatcher.dispatchEvent(new DataEvent(EventName.PetEquipDress, arg2));
                    break;
                }
                case ItemMenuConst.UNDRESS_PETEQUIP:
                {
                    if (ItemsUtil.isMountEquipt(arg2)) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.MountEuqipUndress, arg2));
                        break;
                    }
                    Dispatcher.dispatchEvent(new DataEvent(EventName.PetEquipUndress, arg2));
                    break;
                }
                case ItemMenuConst.UNDRESSALL_PETEQUIP:
                {
                    if (ItemsUtil.isMountEquipt(arg2)) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.MountEquipAllUndress));
                        break;
                    }
                    Dispatcher.dispatchEvent(new DataEvent(EventName.PetEquipUndressAll, null));
                    break;
                }
                case ItemMenuConst.MOREOPER_PETEQUIP:
                {
                    break;
                }
                case ItemMenuConst.DISPOSE_SKILLCARD:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.PetExploreUseCard, {"uid": arg2.uid, "isDestroy": true}));
                    break;
                }
                case ItemMenuConst.FEED:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.RuneOpenFeedWindow, arg2));
                    break;
                }
                case ItemMenuConst.INSERT:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.RuneOpenRuneWindow, arg2));
                    break;
                }
                case ItemMenuConst.CRAVE:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.MountOpenCraveModule, arg2));
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }

        public static getOpEnabled(arg1: string, arg2: ItemData): Boolean
        {
            if (!arg2) 
            {
                return false;
            }
            var loc1=arg1;
            switch (loc1) 
            {
                case ItemMenuConst.USE:
                {
                    return true;
                }
                case ItemMenuConst.SHOW:
                {
                    return true;
                }
                case ItemMenuConst.TO_SALE:
                {
                    return !ItemsUtil.isBind(arg2);
                }
                case ItemMenuConst.SPLIT:
                {
                    return arg2.itemAmount > 1;
                }
                case ItemMenuConst.DISPOSE:
                {
                    if (ItemsUtil.isMountEquipt(arg2) && arg2.posType == EPlayerItemPosType._EPlayerItemPosTypeRole) 
                    {
                        return false;
                    }
                    return true;
                }
                case ItemMenuConst.FORGING:
                {
                    if (arg2.type == EEquip._EEquipHeartLock || arg2.type == EEquip._EEquipHarmMedalDeeper || arg2.type == EEquip._EEquipHarmMedalLower) 
                    {
                        return false;
                    }
                    return true;
                }
                case ItemMenuConst.EQUIP:
                {
                    return true;
                }
                case ItemMenuConst.EQUIPFABAO:
                {
                    return ItemsUtil.isMagicWeapon(arg2) && arg2.isHasIdentify();
                }
                case ItemMenuConst.IDENTIFYFABAO:
                {
                    return ItemsUtil.isMagicWeapon(arg2) && !arg2.isHasIdentify();
                }
                case ItemMenuConst.MOVETOWARDROBE:
                {
                    return arg2.type == EEquip._EEquipWing || arg2.type == EEquip._EEquipFashion || arg2.type == EEquip._EEquipFashionWeapon || arg2.type == EEquip._EEquipFootPrint || arg2.type == EEquip._EEquipBubble || arg2.type == EEquip._EEquipSurround || arg2.type == EEquip._EEquipWaistBelt || arg2.type == EEquip._EEquipElf;
                }
                case ItemMenuConst.EQUIPMOUNT:
                {
                    return true;
                }
                case ItemMenuConst.GRADE:
                {
                    return true;
                }
                case ItemMenuConst.BULKUSE:
                {
                    return ItemsUtil.isCanBulkUse(arg2);
                }
                case ItemMenuConst.JEWELUP:
                {
                    return true;
                }
                case ItemMenuConst.FEED:
                {
                    return ItemsUtil.isRune(arg2);
                }
                case ItemMenuConst.INSERT:
                {
                    return ItemsUtil.isRune(arg2);
                }
                case ItemMenuConst.DRESS_PETEQUIP:
                {
                    if (ItemsUtil.isMountEquipt(arg2)) 
                    {
                        return !ItemsUtil.isMountEquipOnMan(arg2);
                    }
                    return !ItemsUtil.isDressInPet(arg2);
                }
                case ItemMenuConst.UNDRESS_PETEQUIP: case ItemMenuConst.UNDRESSALL_PETEQUIP: case ItemMenuConst.MOREOPER_PETEQUIP:
                {
                    if (ItemsUtil.isMountEquipt(arg2)) 
                    {
                        return ItemsUtil.isMountEquipOnMan(arg2);
                    }
                    return ItemsUtil.isDressInPet(arg2);
                }
                default:
                {
                    return true;
                }
            }
        }

        public static getDataProvider(arg1: ItemData): DataProvider
        {
            var loc1=arg1.itemInfo.item.category;
            if (loc1 == ECategory._ECategoryProp || loc1 == ECategory._ECategoryDrug) 
            {
                return ItemMenuConst.Prop;
            }
            if (loc1 == ECategory._ECategoryIllustrate) 
            {
                return ItemMenuConst.Illustrate;
            }
            if (loc1 == ECategory._ECategoryEquip || loc1 == ECategory._ECategorySpiritEquip) 
            {
                return ItemMenuConst.Equip;
            }
            if (loc1 == ECategory._ECategoryAmulet) 
            {
                return ItemMenuConst.Fabao;
            }
            if (loc1 == ECategory._ECategoryMount) 
            {
                if (MountConfig.instance.isCanCrave(arg1)) 
                {
                    return ItemMenuConst.MountCrave;
                }
                return ItemMenuConst.Mount;
            }
            if (loc1 == ECategory._ECategoryJewel) 
            {
                return ItemMenuConst.Jewel;
            }
            if (loc1 == ECategory._ECategoryTask) 
            {
                return ItemMenuConst.Task;
            }
            if (loc1 == ECategory._ECategoryPetEquip) 
            {
                return ItemMenuConst.PetEquip;
            }
            if (loc1 == ECategory._ECategoryRune) 
            {
                return ItemMenuConst.Rune;
            }
            if (loc1 == ECategory._ECategoryMountEquip) 
            {
                return ItemMenuConst.MountEquip;
            }
            return ItemMenuConst.Other;
        }

        public static getEnabeldAttri(arg1: DataProvider, arg2: ItemData): DataProvider
        {
            var loc3=null;
            var loc4=false;
            var loc5=null;
            var loc1=new DataProvider();
            var loc2=0;
            while (loc2 < arg1.length) 
            {
                loc3 = arg1.getItemAt(loc2);
                if (loc4 = ItemMenuConst.getOpEnabled(loc3["label"], arg2)) 
                {
                    loc5 = {"label": loc3["label"], "enabled": loc4};
                    loc1.addItem(loc5);
                }
                ++loc2;
            }
            return loc1;
        }

        public static /* const */DISPOSE: string=Language.getString(42804);

        public static /* const */FORGING: string=Language.getString(42805);

        public static /* const */EQUIP: string=Language.getString(42806);

        public static /* const */EQUIPFABAO: string=Language.getString(42812);

        public static /* const */IDENTIFYFABAO: string=Language.getString(42813);

        public static /* const */EQUIPMOUNT: string=Language.getString(42807);

        public static /* const */GRADE: string=Language.getString(42808);

        public static /* const */BULKUSE: string=Language.getString(42809);

        public static /* const */JEWELUP: string=Language.getString(42810);

        public static /* const */MOVETOWARDROBE: string=Language.getString(42811);

        public static /* const */DRESS_PETEQUIP: string="    " + Language.getString(61312);

        public static /* const */UNDRESS_PETEQUIP: string="   " + Language.getString(61309);

        public static /* const */UNDRESSALL_PETEQUIP: string="   " + Language.getString(61310);

        public static /* const */MOREOPER_PETEQUIP: string="   " + Language.getString(61311);

        public static /* const */DISPOSE_SKILLCARD: string=Language.getString(54583);

        public static /* const */INSERT: string=Language.getString(44061);

        public static /* const */FEED: string=Language.getString(44062);

        public static /* const */TAKEOUT: string=Language.getString(44067);

        public static /* const */CRAVE: string=Language.getString(70173);

        public static /* const */Prop: DataProvider=new DataProvider([{"label": ItemMenuConst.USE}, {"label": ItemMenuConst.BULKUSE}, {"label": ItemMenuConst.SHOW}, {"label": ItemMenuConst.TO_SALE}, {"label": ItemMenuConst.SPLIT}, {"label": ItemMenuConst.DISPOSE}]);

        public static /* const */Illustrate: DataProvider=new DataProvider([{"label": ItemMenuConst.USE}, {"label": ItemMenuConst.SHOW}, {"label": ItemMenuConst.TO_SALE}, {"label": ItemMenuConst.SPLIT}, {"label": ItemMenuConst.DISPOSE}]);

        /* internal */ static /* const */Equip: DataProvider=new DataProvider([{"label": ItemMenuConst.EQUIP}, {"label": ItemMenuConst.MOVETOWARDROBE}, {"label": ItemMenuConst.FORGING}, {"label": ItemMenuConst.SHOW}, {"label": ItemMenuConst.TO_SALE}, {"label": ItemMenuConst.DISPOSE}]);

        /* internal */ static /* const */Fabao: DataProvider=new DataProvider([{"label": ItemMenuConst.IDENTIFYFABAO}, {"label": ItemMenuConst.EQUIPFABAO}, {"label": ItemMenuConst.SHOW}, {"label": ItemMenuConst.TO_SALE}, {"label": ItemMenuConst.DISPOSE}]);

        /* internal */ static /* const */PetEquip: DataProvider=new DataProvider([{"label": ItemMenuConst.DRESS_PETEQUIP}, {"label": ItemMenuConst.UNDRESS_PETEQUIP}, {"label": ItemMenuConst.UNDRESSALL_PETEQUIP}]);

        /* internal */ static /* const */MountEquip: DataProvider=new DataProvider([{"label": ItemMenuConst.DRESS_PETEQUIP}, {"label": ItemMenuConst.UNDRESS_PETEQUIP}, {"label": ItemMenuConst.UNDRESSALL_PETEQUIP}, {"label": ItemMenuConst.DISPOSE}]);

        /* internal */ static /* const */Mount: DataProvider=new DataProvider([{"label": ItemMenuConst.EQUIPMOUNT}, {"label": ItemMenuConst.SHOW}, {"label": ItemMenuConst.TO_SALE}, {"label": ItemMenuConst.DISPOSE}]);

        public static /* const */USE: string=Language.getString(42800);

        /* internal */ static /* const */Jewel: DataProvider=new DataProvider([{"label": ItemMenuConst.JEWELUP}, {"label": ItemMenuConst.TO_SALE}, {"label": ItemMenuConst.SHOW}, {"label": ItemMenuConst.SPLIT}, {"label": ItemMenuConst.DISPOSE}]);

        /* internal */ static /* const */Rune: DataProvider=new DataProvider([{"label": ItemMenuConst.INSERT}, {"label": ItemMenuConst.FEED}, {"label": ItemMenuConst.SHOW}, {"label": ItemMenuConst.DISPOSE}]);

        /* internal */ static /* const */Task: DataProvider=new DataProvider([]);

        /* internal */ static /* const */Other: DataProvider=new DataProvider([{"label": ItemMenuConst.SHOW}, {"label": ItemMenuConst.DISPOSE}]);

        /* internal */ static /* const */MountCrave: DataProvider=new DataProvider([{"label": ItemMenuConst.EQUIPMOUNT}, {"label": ItemMenuConst.SHOW}, {"label": ItemMenuConst.TO_SALE}, {"label": ItemMenuConst.DISPOSE}, {"label": ItemMenuConst.CRAVE}]);

        public static /* const */PetSkillCard: DataProvider=new DataProvider([{"label": ItemMenuConst.DISPOSE_SKILLCARD}]);

        public static /* const */SHOW: string=Language.getString(42801);

        public static /* const */TO_SALE: string=Language.getString(42802);

        public static /* const */SPLIT: string=Language.getString(42803);

        public static /* const */DrugBag: DataProvider=new DataProvider([{"label": ItemMenuConst.USE}, {"label": ItemMenuConst.BULKUSE}]);
    }
